package com.xian.im.common.proto;

import com.xian.im.common.model.vo.UserDetail;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @program: xian-code
 * @description:
 * @author: liru.xian
 * @create: 2021-01-23 15:39
 **/
@Data
@EqualsAndHashCode
@ApiModel(
        value = "xim 即时通讯事件回调消息体"
)
public class MsgResponse extends MsgMessage {

    @ApiModelProperty("out_uniqueId 合作结构消息ID，合作方自定义")
    private String outUniqueId;
    @ApiModelProperty("事件类型")
    private String  eventType;
    @ApiModelProperty("code错误码 0 正常 其他错误")
    private Integer code;
    @ApiModelProperty("返回消息")
    private String msg;
    @ApiModelProperty("用户信息")
    private UserDetail user;
    @ApiModelProperty("群组ID 如果是群组消息请带上群组的唯一ID")
    private String groupUniqueId;
    @ApiModelProperty(" true是回执消息，false为非回执消息")
    private boolean isCallback = false;

    public static MsgResponse buildSuccess(){
        MsgResponse response = new MsgResponse();
        response.setCode(1);
        response.setMsg("ok");
        response.setTimestamp(System.currentTimeMillis()+"");
        return response;
    }
    public static MsgResponse buildError(Integer errorCode ,String errorMsg){
        MsgResponse response = new MsgResponse();
        response.setCode(errorCode);
        response.setMsg(errorMsg);
        return response;
    }

}
